<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('sahngpin列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>商品名：</label>
                            <input type="text" name="shangpinming"/>
                        </li>
                        <li>
                            <label>商品类别：</label>
                            <input type="text" name="shangpinleibie"/>
                        </li>
                        <li>
                            <label>规格宽：</label>
                            <input type="text" name="shangpinguigekuan"/>
                        </li>
                        <li>
                            <label>规格高：</label>
                            <input type="text" name="shangpinguigegao"/>
                        </li>
                        <li>
                            <label>开向：</label>
                            <input type="text" name="shangpinkaixiang"/>
                        </li>
                        <li>
                            <label style="width: auto;">商品进货价：</label>
                            <input type="text" name="shangpinjinhuojia"/>
                        </li>
                        <li>
                            <label>商品售价：</label>
                            <input type="text" name="shangpinshoujia"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="cangku:shangpin:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="cangku:shangpin:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="cangku:shangpin:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="cangku:shangping:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('cangku:shangping:edit')}]];
    var removeFlag = [[${@permission.hasPermi('cangku:shangping:remove')}]];
    var prefix = ctx + "cangku/shangpin";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "商品列表",
            showColumns: false,
            showToggle: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id主键',
                    visible: false
                },
                {
                    field: 'shangpinming',
                    title: '商品名',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shengchanchangshang',
                    title: '生产厂家',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpinleibie',
                    title: '商品类别',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpinguigekuan',
                    title: '规格宽',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpinguigegao',
                    title: '规格高',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpinkaixiang',
                    title: '开向',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpintupian',
                    title: '商品图片',
                    align: 'center',
                    halign: 'center',
                    formatter: function (value, row, index) {
                        const actions = [];
                        if (value !== "" && value !== null) {
                            actions.push('<img alt="" src="' + value + '" style="width: 150px;height: 150px;object-fit: contain">');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'shangpintiaoma',
                    title: '商品条码',
                    align: 'center',
                    halign: 'center',
                    formatter: function (value, row, index) {
                        const actions = [];
                        if (value !== "" && value !== null) {
                            actions.push('<img alt="" src="' + value + '" style="width: 150px;height: 150px;object-fit: contain">');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'shangpinjinhuojia',
                    title: '商品进货价',
                    align: 'center',
                    halign: 'center'
                },
                {
                    field: 'shangpinshoujia',
                    title: '商品售价',
                    align: 'center',
                    halign: 'center'
                },
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>